package main.www.wonderfuldata.servlet;



import main.www.wonderfuldata.bean.Temp;
import main.www.wonderfuldata.bean.User2;
import main.www.wonderfuldata.com.StatementTest;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.List;




@WebServlet(name = "shujuTest",urlPatterns ={"/shujuTest"})
public class shujuTest extends HttpServlet {




    public void service(HttpServletRequest request ,HttpServletResponse response) throws IOException, ServletException {

        request.setCharacterEncoding("utf8");

        StatementTest st = new StatementTest();
        String sql = "select *from shujuTest";
        List<Temp> listTemp = st.getAllInstance(Temp.class,sql);


        java.awt.List list = new java.awt.List();
        list.add("1");
        list.add("2");
        list.add("3");



        System.out.println(list.getItem(1).toString());

        //return listTemp;
        request.setAttribute("listTemp",listTemp);
        request.setAttribute("list",list);



        StatementTest st1 = new StatementTest();
        String sql1 = "select * from User";
        List<User2> userList  =  st1.getAllInstance(User2.class,sql1);
        request.setAttribute("userList",userList);




        System.out.println(listTemp);
        request.getRequestDispatcher("temp.jsp").forward(request,response);
    }


}
